<html>
<head>
    <script src="/jquery-2.2.3.min.js"></script>
    <script src="/method.js"></script>
</head>
<body>
this is product list
<table>
    <th><td>编号</td><td>名称</td><td>价格</td></th>
<#if productList??>
    <#list productList as vo>
        <tr>
            <td>${vo.id?if_exists}</td>
            <td>${vo.name?if_exists}</td>
            <td>${vo.price?if_exists}</td>
            <td><input type="button" value="加入购物车" onclick="addProduct(${vo.id?if_exists})"/></td>
        </tr>
    </#list>
</#if>
</table>
<a href="/">返回</a>
<script>
    function addProduct(id){
        var data = {
            id: id
        };
        var url = "/addProduct/doaddProduct";
        postReq(url,data,function (result) {
            alert("商品已加入购物车")
        }) ;
    }
</script>
</body>
</html>